﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DAO;
using DTO;
using BUS;

namespace GUI
{
    public partial class BaoCaoTongKetMon : Form
    {
        public BaoCaoTongKetMon()
        {
            InitializeComponent();
        }



        private void btThem_Click(object sender, EventArgs e)
        {
            int indexMonHoc = cbMonHoc.SelectedIndex;
            string monHoc = null;
            if (indexMonHoc >= 0)
                monHoc = cbMonHoc.Items[indexMonHoc].ToString();
            else
                MessageBox.Show("Chưa chọn môn học");

            int indexHocKy = cbHocKy.SelectedIndex;
            string hocKy = null;

            if (indexHocKy >= 0)
                hocKy = cbHocKy.Items[indexHocKy].ToString();
            else
                MessageBox.Show("Chưa chọn Lớp học");

           DataTable tb =  TongKetMonBUS.DanhSach( monHoc, hocKy );
           
           grvTongKetMon.DataSource = tb;
           grvTongKetMon.Refresh();

        }
        
        private void cbMonHoc_Click(object sender, EventArgs e)
        {
            DataTable tbMonHoc = MonHocBUS.LayDuLieuMonHoc();

            int irow = tbMonHoc.Rows.Count;
            cbMonHoc.Items.Clear();
            for (int i = 0; i < irow; i++ )
                cbMonHoc.Items.Add( tbMonHoc.Rows[i][0] );
            
            cbMonHoc.Refresh();
        }

        private void btLuu_Click(object sender, EventArgs e)
        {
            DataTable tb = new DataTable();
            tb = grvTongKetMon.DataSource as DataTable;
            if (tb != null)
            {
                TongKetMonDAO.LoadDuLieuXuong(tb);
                MessageBox.Show(this, "Lưu thành công ^^", "Thông báo", MessageBoxButtons.OK);
            }
        }

 



 
        

    }
}
